package com.bay1ts.dao;

import com.bay1ts.domain.Users;
import org.apache.ibatis.annotations.Param;

import java.util.Date;

public interface UsersMapper {

    /*
    * -------------------------------------------------
    * 100%手写代码 coded by bay1ts
    * -------------------------------------------------
    *
    * */


    //忘记密码相关
    public boolean existToken(String token);//ok
    public Date getDateByToken(String token);//ok
    public String getUserNameByEmail(String email);//ok
    public String getCodeByEmail(String email);//ok
    public String getEmailByCode(String code);//ok
    public void updatePasswordByEmail(@Param("email") String email, @Param("password") String password);//ok
    //这里的参数，都是根据所在service里有啥参数来确定的。
    public void cleanupAfterSuccess(String email);//ok
    //忘记密码相关结束

    //动态密码登录相关开始
    public void updateDynamicCode(String phonenumber,int code);
    public int getDynamicCodeByPhonenumber(String phonenumber);
    public Date getDateByCode(int code);
    public String getUsernameByPhonenumber(String phonenumber);
    //动态密码登录相关结束
    //public void insertAuthority(UserDetailsWarpper user);
    public void insertGroup(Users user);//ok
    public void deleteUser(String username);
    public boolean existCode(int code);
    /**
     * @param email
     * @param token
     * @param date
     * 这里的date还可能有点问题呢，这是java的date，不是mysql的timestamp，应该在mybatis里转换下。
     * 给忘记密码的孩子生成链接，链接的token部分存储在这了，还有生成链接的时间，用于超过多久后就失效
     */
    public void updateReset_pw_Token_Time(@Param("email") String email, @Param("token") String token, @Param("date") Date date);//ok
    public void updateDynamic_Login_Code_Time(@Param("phonenumber") String phonenumber,@Param("code") int code,@Param("date")Date date);
    public int getMajorIdByStudentId(Long id);//ok
    public int getDepartmentIdByMajorId(int id);//ok



    /*
    * -------------------------------------------------
    * 100%手写代码 coded by bay1ts
    * -------------------------------------------------
    *
    * */

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table users
     *
     * @mbggenerated
     */
    int deleteByPrimaryKey(Long id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table users
     *
     * @mbggenerated
     */
    int insert(Users record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table users
     *
     * @mbggenerated
     */
    int insertSelective(Users record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table users
     *
     * @mbggenerated
     */
    Users selectByPrimaryKey(Long id);
    Users selectByUsername(Long id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table users
     *
     * @mbggenerated
     */
    int updateByPrimaryKeySelective(Users record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table users
     *
     * @mbggenerated
     */
    int updateByPrimaryKey(Users record);
}